package labox.innovation.gameserver.network.clientpackets;

import labox.innovation.gameserver.model.L2Party;
import labox.innovation.gameserver.model.actor.instance.FuzePcInstance;
import labox.innovation.gameserver.network.SystemMessageId;
import labox.innovation.gameserver.network.serverpackets.PartySmallWindowDeleteAll;
import labox.innovation.gameserver.network.serverpackets.SystemMessage;

/**
 * @author ljsh
 * @date 2010-4-9
 * @version 1.0
 * @description 解散队伍
 */
public class RequestDisbandParty extends L2GameClientPacket {
	private static final String _C__RequestDisbandParty = "[C]  RequestDisbandParty";

	@Override
	public String getType() {

		return _C__RequestDisbandParty;
	}

	@Override
	protected void readImpl() {
	}

	@Override
	protected void runImpl() {
		FuzePcInstance player = getClient().getActiveChar();
		SystemMessage msg = null;
		L2Party party = null;
		if (player == null) {
			return;
		}
		if (!player.isInParty()) {
			msg = new SystemMessage(SystemMessageId.YOU_ARE_NOT_IN_THE_PARTY);
			player.sendPacket(msg);
			return;
		}
		party = player.getParty();
		if (!party.isLeader(player)) {
			msg = new SystemMessage(SystemMessageId.YOU_ARE_NOT_THE_LEADER_OF_THE_PARTY);
			player.sendPacket(msg);
			return;
		}
		for (FuzePcInstance temp : party.getPartyMembers()) {
			temp.setParty(null);
			party.getPartyMembers().remove(temp);
			temp.sendPacket(new PartySmallWindowDeleteAll());
		}
		msg = new SystemMessage(SystemMessageId.YOUR_PARTY_HAS_BEEN_DISBANDED);
		player.sendPacket(msg);
	}

}
